package com.gaussian.property.module.biz.enums;

import lombok.Getter;

/**
 * @description: 事件类型
 * @author: songqi(13776346982)
 * @date: 2023/8/11 11:04
 */
@Getter
public enum Sex {


    /**
     * 性别
     */
    FEMALE("M", "女"),
    MALE("F", "男"),
    UNKNOWN("U", "未知"),
    ;

    private final String code;


    private final String desc;

    Sex(String code, String desc){
        this.code = code;
        this.desc = desc;
    }

    // 根据name返回枚举对象
    public static Sex getSexByCode(String code) {
        for (Sex sex : Sex.values()) {
            if (sex.getCode().equals(code)) {
                return sex;
            }
        }
        return null;
    }

    // 根据name返回desc
    public static String getDescByCode(String code) {
        Sex sex = getSexByCode(code);
        if(sex != null){
            return sex.getDesc();
        }
        return null;
    }

}
